<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<title><?php echo C("SITE_NAME");?>管理后台</title>
<link rel="shortcut icon" href=" /favicon.ico" />
<link rel="stylesheet" href="/Static/admin/css/component-min.css">
<link rel="stylesheet" href="/Static/admin/css/home.2015.05.22-09.32.css">
<link rel="stylesheet" href="/Static/admin/icon/iconfont.css">
<!--弹窗-->
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script src="/Static/admin/js/layer-2.x/layer.js?v=1.9.0"></script>
<script src="/Static/admin/js/common.js"></script>
<script>
	var UPYUN_DOMAIN = '<?php echo C("UPYUN_DOMAIN");?>';
</script>
</head>
<body class="cp-bodybox">
<!--[if lt IE 9]>
<div class="alert alert-danger disable-del txtCenter" id="tipLowIEVer">
    <h4>系统检测到您使用的浏览器版本过低，为达到更好的体验效果请升级您的浏览器，我们为您推荐：</h4>
    <p>
        <a href="http://www.firefox.com.cn/download/" target="_blank">Firefox浏览器</a>
        <a href="http://www.maxthon.cn/" target="_blank">遨游浏览器</a>
        <a href="http://se.360.cn/" target="_blank">360浏览器</a>
    </p>
</div>
<![endif]-->
<style>
.header-nav-list a {
  display: block;
  padding: 0 10px;
  min-width: 70px;
  line-height: 53px;
  font-size: 14px;
  text-align: center;
  font-weight: 700;
}
</style>

<div class="header">
    <div class="inner clearfix">
        <div class="fl">
            <a href="/" class="header-logo">
                <img
                    src="<?php echo C('UPYUN_DOMAIN'); echo C('SITE_TOPLOGO2');?>"
                    onerror="javascript:this.src='/Static/admin/images/error.png';"
                    ></a>
        </div>
        <!-- end logo -->

        <div class="header-nav fl">
            <ul class="header-nav-list clearfix">
                <!--<li class="fl <?php echo ($controller == 'index')?'active':'';?>"><a href="/admin">首页</a></li>-->
                <?php foreach($MENU as $k=>$v){?>
                <li class="fl <?php echo ($controller == $v['controller'])?'active':'';?>">
                    <a href="<?php echo $v['url'];?>"><?php echo $v['title'];?></a>
                </li>
                <?php } ?>
            </ul>
        </div>
        <!-- end header-nav -->

        <div class="fr">
            <ul class="header-ctrl clearfix">
                <li class="header-ctrl-item fl"><a href="/admin/login/logout">退出</a></li>
            </ul>
        </div>

        <span class="account_inbox_switch fr"></span>
        <span class="header-welcome fr">
            <a href="javasecript:;" class="tips" data-trigger="hover" data-placement="top"><?php echo $admininfo['username'];?></a>
        </span>

    </div>
</div>
<!-- end header -->
	<div class="container">
		<div class="inner clearfix">
	<div class="content-left fl">
    <?php foreach($SUBMENU as $subkey=>$sub){ ?>
    <dl class="left-menu shop_8">
        <dt>
            <i class="icon-menu home"></i> <span id="shop_0" data-id="0"><?=$sub['title']?></span>
        </dt>
        <?php foreach($sub['menu'] as $menu){ ?>
        <dd class="<?php echo ($action == $menu["action"])?'active':'';?>">
            <a href="<?=$menu['url']?>"><?=$menu['title']?></a>
        </dd>
        <?php } ?>
    </dl>
    <?php } ?>
</div>
<style>
#uploadPic {
	padding:0px 0px 20px 0px;
	height:auto;
}
#uploadPic ul {
	list-style-type:none;
	margin:0px;
	padding:0px;
	border:0;
	float:left;
}
#uploadPic li {
	float:left;
	width:82px;
	height:88px;
	margin:0 5px 5px 0;
	padding-bottom:3px;
	overflow:hidden;
	background:#eee;
	position:relative
}
#uploadPic .displayimg {
	width:76px;
	height:60px;
	border:1px solid #ccc;
	overflow:hidden;
	background:#fff;
	padding:2px;
	text-align:center;
	vertical-align:middle;
}
#uploadPic .displayimg img {
	width:76px;
	height:60px;
}
#uploadPic .previous {
	display:inline-block;
	width:13px;
	height:12px;
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat 0 -7px;
	line-height:100px;
	vertical-align:middle;
	overflow:hidden;
	margin:-12px 33px 0 12px;
	margin:7px 33px 0 12px\9;
*margin:7px 33px 0 12px;
	_margin:7px 33px 0 12px;
}
#uploadPic .previous:hover {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat 0 -19px;
}
#uploadPic .previous:active {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat 0 -7px;
}
#uploadPic .next {
	display:inline-block;
	width:13px;
	height:12px;
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat -14px -7px;
	line-height:100px;
	vertical-align:middle;
	overflow:hidden;
	margin:-12px 0 0;
	margin:7px 0 0\9;
*margin:7px 0 0;
	_margin:7px 0 0;
}
#uploadPic .next:hover {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat -14px -19px;
}
#uploadPic .next:active {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat -14px -7px;
}
#uploadPic .delete {
	display:block;
	width:13px;
	height:12px;
	background:url(/Static/admin/js/swfupload/img/closeyes.gif) no-repeat 0 0;
	line-height:100px;
	overflow:hidden;
	position:absolute;
	top:3px;
	right:3px;
	z-index:999
}
#uploadPic .delete:hover {
	background:url(/Static/admin/js/swfupload/img/close-hover.gif) no-repeat 0 0;
}
#uploadPic .front-cover {
	position:absolute;
	bottom:5px;
    *bottom:-8px;
	left:30px;
	color:#666
}
#uploadPic div {
	clear:both;
}
#uploadPic input.picDesc {
	width:80px;
*width:78px;
	text-align:center;
	margin:0;
	border:1px solid #7F9DB9;
	margin-top:2px;
	display:none;
}
#uploadPic span.upload_error {
	background-color:#FFD7D7;
	color:#000;
	padding:4px;
	font-family:Tahoma;
	line-height:24px;
}
#upload_tip {
	padding-left:15px;
	height:27px;
	line-height:27px;
}
#upload_tip span {
	color:#F30
}
.purviews {
	padding:10px 300px 10px 10px;
}
.purviews p{
	line-height:18px;
}
.purviews span {
	font-variant:normal;
	display:block;
	float:left;
	width:12%;
}
.jindubox {
	width:500px;
	margin:0 auto;
	height:30px;
	background: #CCC;
}
.jindu {
	color:#FFF;
	font-size:12px;
	font-weight:bolder;
	background:url(/Static/admin/js/swfupload/img/bfbg.gif) left top repeat-x;
	height:30px;
}
    </style>
<script type="text/javascript" src="/Static/admin/js/swfupload/swfupload.js" ></script>
<script type="text/javascript" src="/Static/admin/js/swfupload/multiupload.js" ></script>

<div class="content-right fl">
    <h1 class="content-right-title">发布商品</h1>
    
<ul class="wizard">
    <li class="wizard-item process">
        <dl class="wizard-item-content">
            <dt class="wizard-ic-step">
                <span class="wizard-icstp-num">1</span>
                <span class="wizard-icstp-title">编辑发现信息</span>
            </dt>
            <dd class="wizard-ic-desc"></dd>
        </dl>
    </li>
    <li class="wizard-item">
        <dl class="wizard-item-content">
            <dt class="wizard-ic-step">
                <span class="wizard-icstp-num">2</span>
                <span class="wizard-icstp-title">发布</span>
            </dt>
        </dl>
    </li>
</ul>
<form id="form" aciton="" method="post" id="add" onsubmit="return false">

  
	
<div class="panel-single panel-single-light mgt20">
    <h3 class="cst_h3 mgb20">发现</h3>

	<div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>发现标题：</label>
        <div class="form-controls">
            <input type="text" class="input xxlarge" name="share_title" value="<?php echo $goods['share_title'];?>" maxlength="22">
            <span class="fi-help-text">最长22个字</span>
        </div>
    </div>
	
    <div class="formitems">
        <label class="fi-name">发现分类：</label>
        <div class="form-controls">
			<select name="share_type" class="select small newselect">
				<option value="" selected="">未分类</option>
				<?php foreach($gtype as $k=>$v){ ?>
				<option value="<?php echo $v['type_id'];?>"  <?php echo $v['type_id']==$goods['share_type']?"selected":"";?>><?php echo $v['type_name'];?></option>
				<?php } ?>
			</select>
            <span class="fi-help-text">请选择发现分类</span>
        </div>
    </div>


	<div class="formitems">
        <label class="fi-name"><span class="colorRed"></span>排序：</label>
        <div class="form-controls">
            <input type="number" class="input xxlarge" name="ord" value="<?php echo $goods['ord'];?>" maxlength="22">
            <span class="fi-help-text">排序数字，越小越靠前</span>
        </div>
	</div>
	
    <!--
    <?php foreach($gradeList as $grade) { ?>
        <div class="formitems">
            <label class="fi-name"><span class="colorRed">*</span><?=$grade['grade_name']?>价：</label>
            <div class="form-controls">
                <input type="text" class="input mini"  name="grade<?=$grade['grade_id']?>_price" value="<?php echo $goods['grade'.$grade['grade_id'].'_price'];?>">
                <span>元</span>
            </div>
        </div>
    <?php } ?>
    -->
<!--    <div class="formitems">
        <label class="fi-name"><?php echo C('SCORE_NAME');?>可用的比率：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="score_rate" value="<?php echo $goods['score_rate'];?>">
            <span class="fi-help-text">0.01~1,保留5位小数</span>
        </div>
    </div>-->

    
 	 <div class="formitems">
        <label class="fi-name">分享文字内容：</label>
        <div class="form-controls">
            <textarea type="text" class="textarea" name="share_text" style="width: 500px;height: 200px"><?php echo $goods['share_text'];?></textarea>
        </div>
	</div>

    <div class="formitems">
        <div class="form-controls">
            <p class="fi-help-text">
                如需分享视频建议:<br>
                1、点击<a style="color:blue" href="http://v.qq.com/u/upload.html" target="_blank">http://v.qq.com/u/upload.html</a>将视频上传至腾讯视频<br>
                2、上传等待审核完成后，在腾讯视频播放页面左下角点击分享-->将视频链接粘贴至此处<br>
                3、点击保存
            </p>
        </div>
        <label class="fi-name">分享视频链接：</label>
        <div class="form-controls">
            <textarea type="text" class="textarea" name="video_thumb" style="width: 500px;height: 200px"><?php echo $goods['video_thumb'];?></textarea>
        </div>

    </div>


    <div class="formitems">
        <label class="fi-name"></label>
        <div class="form-controls">
            <p class="fi-help-text">
				如需插入视频建议使用方法:<br>
				1、点击<a style="color:blue" href="http://v.qq.com/u/upload.html" target="_blank">http://v.qq.com/u/upload.html</a>将视频上传至腾讯视频<br>
				2、上传等待审核完成后，在腾讯视频播放页面左下角点击分享-->复制通用代码<br>
				3、点击下方编辑器的 HTML 按钮，将步骤2复制的内容粘贴进编辑器，再次点击 HTML 按钮即可预览视频<br>
				4、点击保存按钮
			</p>
        </div>
	</div> 

	<div class="formitems">
        <label class="fi-name">分享视频内容：</label>
        <div class="form-controls">
            <!-- 加载编辑器的容器 -->
			<script id="container" name="share_data" type="text/plain">
				<?php echo htmlspecialchars_decode($goods['share_data']);?>
			</script>
        </div>
	</div> 

	
	<script type="text/javascript" src="/Static/admin/js/ueditor/ueditor.config.only.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="/Static/admin/js/ueditor/ueditor.all.js"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container');
    </script>

    <div class="formitems">
        <label class="fi-name">是否发布：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_hot" value="1" name="ischeck" <?php echo isset($goods['ischeck']) && ($goods['ischeck']) ? "checked" : "";?>>发布</label>
                <label><input type="radio" class="is_hot" value="0" name="ischeck" <?php echo isset($goods['ischeck']) && (!$goods['ischeck']) ? "checked" : (!isset($goods['ischeck']) ? "checked":"");?>>取消发布</label>
            </div>
            <span class="fi-help-text" style="color:red;"></span>
        </div>
    </div>

    <!--<div class="formitems">
        <label class="fi-name">排序：</label>
        <div class="form-controls">

            <input type="text" class="input mini" name="ord" value="<?php echo $goods['ord'];?>">
            <span class="fi-help-text">数字越小越靠前,越大越靠后</span>
        </div>
    </div>-->

    <div class="formitems">
        <label class="fi-name"><span class="colorRed"></span>分享主图：</label>
	    <div class="form-controls pdt5 j-imglistPanel">

    <div id="uploadPic">
      <ul id="uploadlist" style=" height:90px; overflow:hidden;">
		<?php $sx=0;$p = json_decode($goods['share_thumb'],true);foreach($p as $k=>$v){?>
	        <li>
	          <div class="displayimg"><img src="<?php echo C("UPYUN_DOMAIN").$v;?>" /></div>
	          <a class="previous" href="javascript:void(0);"></a>
	          <span class="front-cover"><?php echo $sx==0 ? "封面":"";$sx++;?></span>
	          <a class="next" href="javascript:void(0);"></a>
	          <a class="delete" href="javascript:void(0);"></a>
	          <input type="hidden" name="goods_thumb[]" id="goods_thumb" value="<?php echo $v;?>" class="goods_thumb" />
	        </li>
		<?php } ?>
      </ul>
      <div style="clear:both;"></div>
    </div>
	    <span class="btn btn-primary j-add"><span id="upload"></span></span>
	        <span class="fi-help-text">可以一次性选择多张图片上传,最对可以上传9张图片<br>建议图片尺寸为640px * 640px<br>注意:分享主图不同于详情图</span>
	    </div>
    </div>
    


</div>


<!-- end 物流及其它 -->

<div class="panel-single panel-single-light mgt20 txtCenter">

	<?php if($action=="add"){?>

    <a href="javascript:weSubmit(1);" class="btn btn-primary j-add">新增</a>
	
	<?php }else{?>
	
	<a href="javascript:weSubmit(1);" class="btn btn-primary j-add">保存</a>
	
	<?php }?>



    <!--<a href="javascript:weSubmit(2);" class="btn btn-primary j-add">保存并进入下 一 步</a>-->
</div>
</form>

</div>
<script type="text/javascript">
$(window).load(pageInit);
function pageInit(){
	
  var ext = '图片(*.gif;*.jpg;*.png;*.jpeg)';//默认值
  ext = ext.match(/([^\(]+?)\s*\(\s*([^\)]+?)\s*\)/i);
  
  swfu = new SWFUpload({
    flash_url : "/Static/admin/js/swfupload/swfupload.swf",
    prevent_swf_caching : false,//是否缓存SWF文件
    upload_url: '/admin/goods/uploadpic', //上传文件路径
    file_post_name : "imgFile",
    post_params:  {'mychatpath':'goods','imgcut':'1'},//随文件上传一同向上传接收程序提交的Post数据
    use_query_string : false,//是否用GET方式发送参数
    file_types : ext[2],//文件格式限制
    file_types_description : ext[1],//文件格式描述
    file_size_limit : '1MB',	//文件大小限制
    file_queue_limit:0,//上传队列总数
    file_upload_limit:9,//最多5张
    custom_settings : {
      test : "aaa"
    },
    file_queued_handler : fileQueued,//添加成功
    file_queue_error_handler : fileQueueError,//添加失败
    file_dialog_complete_handler : fileDialogComplete,
    upload_start_handler : uploadStart,//上传开始
    upload_progress_handler : uploadProgress,//上传进度
    upload_error_handler : uploadError,//上传失败
    upload_success_handler : uploadSuccess,//上传成功
    upload_complete_handler : uploadComplete,//上传结束
    button_placeholder_id : "upload",
    button_width: 80,
    button_height: 50,
    button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
    button_cursor: SWFUpload.CURSOR.HAND,
    button_text : '<span class="redText">点击上传</span>',
    button_text_style: ".redText {color:#ffffff;}",
    button_text_left_padding: 10,
    button_text_top_padding: 5,
    debug: false
  });
}
</script>
<script>
function weSubmit(go){

	$.ajax({
		url : '/admin/share/addShare?share_id=<?php echo get("share_id");?>',
		type : "POST",
		data : $('#form').serialize(),
		dataType : 'json',
		async : false,
		success : function(data) {
			layer.closeAll('loading');//关闭正在加载
			if(data.ret == 0){
				// 成功
				var messagetype = 1;
			}else{
				// 失败
				var messagetype = 2;
			}
			if (data.url) {
				// 如果有跳转地址
				layer.msg(data.msg,{icon: messagetype}, function(){
					window.location.href = data.url;//跳转
				}); 
				
			} else {
				layer.msg(data.msg, {icon: messagetype});
			}
		},
		beforeSend:function(){
			layer.load();//正在加载
       },
       error: function() {
		   layer.closeAll('loading');//关闭正在加载
		   layer.msg("网络错误,请重试", {icon: 2});
       }
       
	});
}



//运费
$(".j-feight").change(function() {
	var a = $(".j-feight-ipt"),
		b = $("#freight_tpl_id");
	switch ($(this).val()) {
	case "1":
		a.attr("disabled", !0), b.attr("disabled", !0);
		break;
	case "2":
		a.attr("disabled", !1), b.attr("disabled", !0);
		break;
	case "3":
		a.attr("disabled", !0), b.attr("disabled", !1)
	}
});

//商品pv
$("#brokerage_money").change(function() {
	var brokerage_money = $("#brokerage_money").val();
	var shop_price = $("#shop_price").val();
	brokerage_percent = brokerage_money/shop_price*100;
	
	
	$("#brokerage_percent").val(brokerage_percent);

});

$('#add-guige').on('click',function(){
	var count = $('#guige-group').children('.formitems').length;
	if(count>=2){
		layer.msg('最多只能添加两个规格哦', {icon: 7});
		return false;
		}
	var item = '<div class="formitems" style="position:relative">'+
					'<button class="btn btn-danger guige-delete" style="position:absolute;right:20px">删除</button>'+
					'<label class="fi-name">规格：</label>'+
					'<div class="form-controls">'+
						'<input type="text" class="input mini" name="guige_names[]"><br>';
	for(var i=0;i<16;i++){
		item += '<span><input type="text" class="input mini" name="xx['+(count)+'][]" ></span>';
	}
	item += '<span class="fi-help-text">请选填商品规格: 例如: 大号  小号  中号   或  iphone5  iphone6  iphone6s</span>'+
			'</div>'+
			'</div>';
			
	$('#guige-group').append(item);
})

$('#guige-group').on('click','.guige-delete',function(){
    var title = "确定要删除该规格所有内容吗？";
	var self = $(this);
	layer.confirm(title, {
	    btn: ['确定','取消'] //按钮
	}, function(){
		
		var par = self.parents(".formitems");
		par.remove();
		
		//重新排序
		var childs = $('#guige-group').children('.formitems');
		$.each(childs,function(index,item){
			$(item).find("span > input").attr('name',"xx["+index+"][]");
		});
		
		$(".layui-layer").remove();
		$(".layui-layer-shade").remove();
		
	}, function(){
		layer.msg('你取消了删除操作', {icon: 7});
	});
	
	
	
	
});
</script>
		</div>
	</div>
<!--gonggao-->
<div class="footer">&copy; <?php echo date("Y");?> <?php echo C("SITE_NAME");?> , Inc. All rights reserved.</div>
<a href="#" id="j-gotop" class="gotop" title="回到顶部" style="right:45px; display: inline;"></a>
<script type="text/javascript">
$(function(){
    var height1=$(".content-right").height();
    var height2=$(".content-left").height();
    if(parseInt(height1) < parseInt(height2)){
        $(".content-right").css({'min-height': height2});
    }
    $(window).scroll(function() {
		$(this).scrollTop() >= 150 ? $("#j-gotop").fadeIn(300) : $("#j-gotop").fadeOut(300)
	});
});
</script>
</body>
</html>